from rest_framework import serializers
from . import models
class NewsViewSerializers(serializers.Serializer):
    title=serializers.CharField(max_length=32)
    content=serializers.CharField(max_length=1000)
    total_comment=serializers.IntegerField()
    total_views=serializers.IntegerField()

    def create(self, validated_data):
        return models.News.objects.create(**validated_data)

class CommentModelSerializer(serializers.Serializer):
    class Meta:
        model=models.Comment
        fields='__all__'


class NewsModelSerializer(serializers.ModelSerializer):

    class Meta:
        model=models.News
        fields='__all__'